﻿using KalevaAalto.DataPart.Enums;
using Org.BouncyCastle.Asn1.Mozilla;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KalevaAalto.DataPart.Models
{

    public class Style : IStyle
    {

        /// <summary>
        /// 是否换行
        /// </summary>
        public bool WrapText { get; set; } = false;
        /// <summary>
        /// 水平对齐
        /// </summary>
        public HorizontalAlignment HorizontalAlignment { get; set; } = HorizontalAlignment.Center;
        /// <summary>
        /// 垂直对齐
        /// </summary>
        public VerticalAlignment VerticalAlignment { get; set; } = VerticalAlignment.Center;

        public string NumberFormat { get; set; } = string.Empty;
        /// <summary>
        /// 字体
        /// </summary>
        public IFont Font { get; } = new Font();

        

        public FontWeight FontWeight { get=>Font.Weight; set=>Font.Weight=value; }
        public float FontSize { get => Font.Size;set=>Font.Size=value; }
        public Color FontColor { get=>Font.Color;set=>Font.Color=value; }
        public string FontName { get=>Font.Name;set=>Font.Name=value; }

        public UnderLineStyle FontUnderLineStyle { get => Font.UnderLine; set => Font.UnderLine = value; }

        public IBorder Border { get; } = new Border();
        public BorderStyle BorderLeft { get => Border.Left; set => Border.Left =value; }
        public BorderStyle BorderRight { get => Border.Right;set => Border.Right =value; }
        public BorderStyle BorderTop { get => Border.Top;set => Border.Top =value; }
        public BorderStyle BorderBottom { get=>Border.Bottom;set => Border.Bottom =value; }


        public IFill Fill { get; } = new Fill();


        public BorderStyle BorderStyle
        {
            set
            {
                Border.Left = value;
                Border.Right = value;
                Border.Top = value;
                Border.Bottom = value;
            }
        }


        public Color BackgroupColor { get => Fill.BackgroundColor; set => Fill.BackgroundColor = value; }





    }
    public interface IStyle
    {
        /// <summary>
        /// 是否换行
        /// </summary>
        public bool WrapText { get; set; }
        /// <summary>
        /// 水平对齐
        /// </summary>
        public HorizontalAlignment HorizontalAlignment { get; set; }
        /// <summary>
        /// 垂直对齐
        /// </summary>
        public VerticalAlignment VerticalAlignment { get; set; }
        /// <summary>
        /// 字体
        /// </summary>
        public IFont Font { get; }

        public IBorder Border { get; }

        public IFill Fill { get; }

        public string NumberFormat { get; set; }


        public BorderStyle BorderStyle
        {
            set
            {
                Border.Left = value;
                Border.Right = value;
                Border.Top = value;
                Border.Bottom = value;
            }
        }


        public Color BackgroupColor { get => Fill.BackgroundColor; set => Fill.BackgroundColor = value; }




        public void Prase(IStyle style)
        {
            WrapText = style.WrapText;
            HorizontalAlignment = style.HorizontalAlignment;
            VerticalAlignment = style.VerticalAlignment;
            Font.Prase(style.Font);
            NumberFormat = style.NumberFormat;
            Border.Parse(style.Border);
            Fill.Parse(style.Fill);
        }
    }
}
